<?php
$conn = @mysqli_connect("localhost","root","","abcd");
if (!$conn){
    die("连接数据库失败：" . mysqli_error());
}
header("Content-type:text/html;charset=utf-8");
//用户名检测
$sqliTwo="select uid from user";
$check_queryTwo = mysqli_query($conn,$sqliTwo);
$numTwo = mysqli_num_rows($check_queryTwo);
$mynumber=@$_POST['mynumber'];
$password=@$_POST['password'];
$passwordT=@$_POST['passwordT'];
$myemail=@$_POST['myemail'];
if(strlen($password) < 6 ||strlen($password) >11){
    echo "<script language='javascript'>alert('错误：新密码(6--11)长度不符合规定');history.back();</script>";
}
elseif(!preg_match("/^1[34578]{1}\d{9}$/",$mynumber))
{
    echo "<script language='javascript'>alert('请输入正确的手机号格式');history.back();</script>";
}
/*elseif(!preg_match('/^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/',$myemail))
{
    echo "<script language='javascript'>alert('请您输入合法的邮箱地址');history.back();</script>";
}*/
else {
    $numTwo=$numTwo+1;
    //$sqlTwo="insert into user VALUES ('$numTwo','$username','$password',0)";
    $username=$_POST['username'];
    $sqlTwo="update user set password= '$password',email='$mynumber',telphone='$mynumber' where username='$username'";
    $zhuce=mysqli_query($conn,$sqlTwo);
    if(!$zhuce){
        echo "<script language='javascript'>alert('注册失败')</script>";
        echo "<script language='javascript'>history.back();</script>";
    }else{
        echo "<script language='javascript'>alert('修改密码成功，请重新登录')</script>";
        //header('Location:page.php?info=注销成功');
        echo "<script language='javascript'>location.href='zhuxiao.php?'</script>";
    }
}
?>